1. Field
Embodiments of the invention relate to optimizing tape speed for a sync operation.
2. Description of the Related Art
A host computer may be coupled to a tape drive. The host computer includes cache and executes a host application. The tape drive has tape cartridges for storing data.
Some commands that are received at the tape drive from the host force a sync operation, (e.g., WriteFM 0 non-immediate), and such commands may be referred to as sync commands. Also, sync operations may be performed as a result of a sync command or for other reasons implicitly by the tape drive. Thus, a sync operation may be described as the actual action of the tape drive synchronizing all the data in a data buffer to a tape cartridge. In particular, the tape drive has a data buffer. The host computer sends data in its data buffer to the tape drive, and this data is stored in the data buffer at the tape drive. The sync operation writes the data in the tape drive data buffer onto a tape cartridge.
A sync command (e.g., a WriteFM 0) may be issued to write data from the data buffer (e.g., in cache) to a tape cartridge. In particular, the host application at the host system issues the sync command, and, in response to receiving the sync command, the tape drive writes data in the data buffer of the tape drive to a tape cartridge (i.e., performs the sync operation). Then, the tape drive starts a backhitch motion. Reading from and writing to a tape cartridge occurs in a forward direction, while “backhitch” refers to the tape cartridge moving in a reverse direction.
Writing to a tape cartridge may be described as follows:
1. Write with Speed Sa to Position X (where Sa is a current speed).
2. Decelerate and move to Position Y (which is past position X in a forward direction).
3. Move backward (i.e., in reverse) to Position Z to have enough distance to accelerate to Speed Sb (where Sb is a new speed).
4. Accelerate to Speed Sb.
FIG. 1 illustrates a graph 100 of position versus velocity. The values of Y and Z in graph 100 are calculated using Equations 1 and 2 (below). A backhitch motion typically takes a few seconds. The backhitch time is calculated with speed Sa, speed Sb, and accelerated velocity “A” using Equations 1-3.Y=Sa2/(2*A)  Equation 1Z=Sb2/(2*A)  Equation 2Backhitch_Time(Sa,Sb)=Sa/A+√{square root over ((2*(Y−Z)/A))}+Sb/A  Equation 3
The Backhitch_Time may be described as representing an amount of time to perform the backhitch motion. Because the tape drive cannot write the received data in backhitch motion, the backhitch motion causes a performance penalty if the host application issues many sync commands. The time that the tape drive takes to perform the sync operation is given in Equation 4.Time_of_Sync_Operation=Backhitch_Time(Sa,Sb)+Time_to_Write_Data  Equation 4
FIG. 2 illustrates a graph 200 of time versus velocity. As can be seen in graph 200, the backhitch operation has a decreased velocity followed by an increased velocity over time.
FIG. 3 illustrates a table 300 of approximate times of sync operations (shown under the transaction size columns) based on given speeds, transfer rates, backhitch time, and various transaction sizes. Assuming that the tape drive has 6 speeds and acceleration is 10 m/sec2 (where m represents meters and sec represents seconds), then the maximum transfer rate to write the data to tape is 80 MB/sec (where MB represents megabytes).
The transaction size may be described as the size of data that the host transfers between issuing the sync commands. If the transaction size is small, the slower speed is preferred over the faster speed. For example, if the transaction size is 32 MB, the preferred speed is 2.046 m/sec (where m represents meters and sec represents seconds). In table 300, the values under the Backhitch_Hitch column are calculated using Equation 3, while the values under the transaction size columns are calculated using Equation 4. From Table 300, it can be seen that it is better to select a slower speed if a transaction size is small (e.g., for a transaction size of 32 MB, the smallest time of sync operation is 1.885066667 seconds at speed 2.046 m/sec).
If the transaction size is not small, there are two problems to address. With the first problem, when the tape drive is doing a backhitch, the tape drive does not know whether the host will issue another sync command or not. Therefore, the tape drive does not select an optimal tape speed for the next sync operation at this time. Instead, the tape drive selects a speed based on the host transfer rate. If the host transfer rate is fast, the tape drive selects the faster speed, even though the tape drive should select the slower speed. Again, with reference to Table 300, for a transaction size of 32 MB, the smallest time of sync operation is 1.885066667 seconds at speed 2.046 m/sec, so the slower speed should be selected, but the tape drive may instead select a speed of 5.455 m/sec based on the host transfer rate of 80 MB/sec.
One solution to the first problem is for the tape drive to wait to write until a sync command is received. If the tape drive waits to write (e.g., to check whether the host might issue the sync command later) until the sync command is received, the waiting time leads to poor performance. In addition, the host might not issue a sync command after the backhitch operation, so the tape drive would not know how long to wait for the next sync command. FIG. 4 illustrates a graph 400 of time versus velocity that shows waiting time for a sync operation.
In addition to a backhitch occurring after a sync command is received, a backhitch may occur when the tape drive buffer becomes empty. With the second problem, if the host transfer rate is slow, the backhitch happens in the middle of a write operation before the sync command because the buffer in the tape drive becomes empty in the middle of the write operation. Due to this backhitch, the overall write and sync operation takes longer. FIG. 5 illustrates a graph 500 of time versus velocity and the impact of a buffer empty condition in the middle of a sync operation scenario.
Thus, there is a need in the art for optimizing tape speed for a sync operation.